package com.yunxi.core.util;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

public class StringUtil {

    /**
     * 选装包排序
     * @param customPackCode 选装包CODE （XZBA,XZAB）
     * @return  选装包CODE（XZAB,XZBA）
     */
    public static String customPackCodeSort(String customPackCode) {
        if (StringUtils.isEmpty(customPackCode)) {
            return "";
        }
        String[] strings = customPackCode.split(",");
        Arrays.sort(strings);
        return String.join(",", strings);
    }

    public static String customSqlStr(String customPackCodes){

        if(StringUtils.isNotEmpty(customPackCodes)){

            String[] strs = customPackCodes.split(",");
            StringBuffer sb = new StringBuffer();
            for(int i=0;i<strs.length;i++){
                sb.append("'"+strs[i]+"'");
                if(i!=strs.length-1){
                    sb.append(",");
                }
            }
            return sb.toString();
        }
        return "";
    }
}
